package com.open.capacity.service.impl;


import com.open.capacity.dao.UserDao;
import com.open.capacity.model.UserModel;
import com.open.capacity.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;

/**
 * @author: y_022
 * @date: 19:43-2021/6/23
 * @description:
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;
    @Override
    public UserModel findUserById(UserModel userModel) {
       UserModel userModelBy = userDao.findUserById(userModel);
        return userModelBy;
    }

    @Override
    public void updatePassword(UserModel userModel) {
        /**
         * 使用MD5加密明文密码
         */
        String newPasswd = DigestUtils.md5DigestAsHex(userModel.getPasswd().getBytes());
        userModel.setPasswd(newPasswd);
        userDao.updatePassword(userModel);
    }

    @Override
    public void updateUser(UserModel userModel) {
        userDao.updateUser(userModel);
    }

    @Override
    public void updateAvatar(UserModel userModel) {
        userDao.updateAvatar(userModel);
    }


}
